<?php

namespace Wap\Controller;
use Think\Controller;

class AgentController extends HomeController
{
    public function profile()
    {
        $uid=is_wxlogin();
        $info=M('agent')->where('uid='.$uid)->find();
        $userinfo=session ('user_auth');
        $info['avatar']=$userinfo['headimgurl'];
        $this->assign('info',$info);
        $this->display();
    }

   //出价记录
    public function record(){
        $uid=is_wxlogin();
        $user_list=M('bid_user')->where(array('user_id'=>$uid))->select();
        $this->assign('user_list',$user_list);
        $this->display();
    }



    //我的订单
    public function myauction(){
        $uid=is_wxlogin();
        $order_list=M('order_list')->where(array('user_id'=>$uid))->order('status')->select();
        $this->assign('order_list',$order_list);
        $this->display();
    }

    //退货管理
    public function returnlist(){
        $uid=is_wxlogin();
        $order_list=M('return_list')->where(array('user_id'=>$uid))->select();
        $this->assign('order_list',$order_list);
        $this->display();
    }

    //修改订单状态
    public function setOrderStatus(){
        $where['id']=I('get.id');
        if( M('order_list')->where($where)->setField('status',I('get.status'))) {
            $this->success('操作成功','',true);
        }else{
            $this->error('操作失败！','',true);
        }
    }


    //提交退货单
    public function submitReturnOrder(){
        if(IS_POST){
            $data['return_sn']=getOrderSn();
            $data['order_id']=I('get.order_id');
            $data['user_id']=is_wxlogin();
            $data['create_time']=time();
            $data['return_count']=I('return_count');
            $data['return_des']=I('return_des');
            $data['status']=1;
            $re=M('return_list')->add($data);
            if($re!==false){
                $this->success('提交成功',U('returnlist'),true);
            }else{
                $this->error('提交失败！','',true);
            }
        }else{
            $this->display();
        }

    }



}